// Blends between two materials
var material1 : Material;
var material2 : Material;
var duration = 1.0;
var boolIsBlending:boolean = false;

function Start () 
{
	// At start, use the first material
	var count = 0;
	renderer.material = material1;
}

function Update () 
{
	if (boolIsBlending )
	{
		// ping-pong between the materials over the duration
		var lerp = Mathf.PingPong (Time.time, duration) / duration;
		renderer.material.Lerp (material1, material2, lerp);
	}
	else
	{
		renderer.material = material1;
	}
}
